package tour.customer.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Service;

import tour.customer.to.MemberTO;

@Service
public class MemberDAO {

	@Autowired
	private SqlMapClientTemplate sqlMap;
	
	public MemberDAO(SqlMapClientTemplate sqlMap){
		this.sqlMap = sqlMap;
	} 
	public MemberDAO(){}
	public MemberTO selectMemberInfoByIdController(String id) throws SQLException{
		return (MemberTO)sqlMap.queryForObject("selectMemberInfoByIdController", id);		
	}
	
	public void insertMember(MemberTO member)throws SQLException{
		sqlMap.insert("insertMember",member);
	}

	//회원정보수정
	public void updateMemberInfoController(MemberTO m) throws SQLException{
		sqlMap.update("updateMemberInfoController", m);
	}
	
	public ArrayList address(String address) throws SQLException{
		return (ArrayList)sqlMap.queryForList("addressC", address);
	}
	
	//탈퇴
	public void deleteMember(String member) throws SQLException{
		sqlMap.delete("deleteMember",member);
	}
	
	//아이디찾기
	public String searchId(MemberTO m) throws SQLException{
		return (String)sqlMap.queryForObject("searchId", m);		
	}
	
	//패스워드찾기
	public String searchPassword(MemberTO m) throws SQLException{
		return (String)sqlMap.queryForObject("searchPassword", m);		
	}
	
	
	// 회원조회
	public ArrayList memberList() throws SQLException{
		return (ArrayList)sqlMap.queryForList("memberList");
	}
	
	//닉네임 조회
	public ArrayList memberNickList(String nickname) throws SQLException {
		return(ArrayList)sqlMap.queryForList("memberNickList", nickname);
		
	}
	
	
}